"use strict";

var gulp = require('gulp');
var browserSync = require('browser-sync');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
// var base64=require('gulp-base64');
var cleanCss = require('gulp-clean-css');
gulp.task('browser-sync', function () {
  browserSync.init({
    server: {
      baseDir: './',
      index: 'html/mybook_none.html'
    }
  });
  gulp.watch("src/css/**/*.css").on('change', browserSync.reload);
  gulp.watch("src/js/**/*.js").on('change', browserSync.reload);
  gulp.watch("html/**/*.html").on('change', browserSync.reload);
});

gulp.task('sass', function () {
  return gulp.src('./src/scss/style.scss')
    .pipe(sass().on('error', sass.logError))
    .pipe(autoprefixer({
      browsers: ['last 2 versions'],
      cascade: false
    }))
    .pipe(cleanCss())
    .pipe(gulp.dest('./src/css/'))
    .pipe(gulp.dest('../src/assets/css/'));
});

gulp.task('sass:watch', function () {
  gulp.watch('./src/scss/*.scss', ['sass']);
});


gulp.task('default', ['browser-sync', 'sass:watch']);
